//
//  ICMTitleSubTitleView.m
//  ICrEAM
//
//  Created by kuroro on 16/11/2.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "ICMTitleSubTitleView.h"

@implementation ICMTitleSubTitleView

- (instancetype)initICMTitleSubTitleViewWithTitle:(NSString *)title subtitle:(NSString *)subtitle{
    if (self = [super init]) {
        __weak typeof(self) weakSelf = self;
        
        UILabel *titleLabel = [[UILabel alloc]init];
        titleLabel.font = NaviFont;
        [title isEqualToString:@"欠款金额"] ? (titleLabel.textColor = WarningColor_Red) : (titleLabel.textColor = TitleColor_Dark);
        titleLabel.text = title;
        [self addSubview:titleLabel];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.mas_top);
            make.centerX.equalTo(weakSelf.mas_centerX);
        }];
        
        self.subtitleLabel = [[UILabel alloc]init];
        self.subtitleLabel.font = ContentFont;
        self.subtitleLabel.textColor = ContentTextColor_Black;
        self.subtitleLabel.text = IsStrEmpty(subtitle)?@"":subtitle;
        self.subtitleLabel.textAlignment = NSTextAlignmentCenter;
        self.subtitleLabel.backgroundColor = TextFeildBackgroundColor_Gray;
        [self addSubview:self.subtitleLabel];
        [self.subtitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.mas_left);
            make.right.equalTo(weakSelf.mas_right);
            make.bottom.equalTo(weakSelf.mas_bottom);
            make.height.equalTo(@(ActualHeight(30)));
        }];
        
    }
    return self;
   
}

- (instancetype)initICMTitleSubTitleViewWithTitle:(NSString *)title subtitle:(NSString *)subtitle frame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.frame = frame;
        __weak typeof(self) weakSelf = self;
        
        UILabel *titleLabel = [[UILabel alloc]init];
        titleLabel.font = NaviFont;
        [title isEqualToString:@"欠款金额"] || [title isEqualToString:@"应收账款"]? (titleLabel.textColor = WarningColor_Red) : (titleLabel.textColor = TitleColor_Dark);
        titleLabel.text = title;
        [self addSubview:titleLabel];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.mas_top);
            make.left.equalTo(weakSelf.mas_left);
        }];
        
        self.subtitleLabel = [[UILabel alloc]init];
        self.subtitleLabel.font = NaviFont;
        self.subtitleLabel.textColor = ContentTextColor_Black;
        self.subtitleLabel.text = subtitle;
        self.subtitleLabel.textAlignment = NSTextAlignmentLeft;
//        self.subtitleLabel.backgroundColor = TextFeildBackgroundColor_Gray;
        [self addSubview:self.subtitleLabel];
        [self.subtitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.mas_left);
            make.right.equalTo(weakSelf.mas_right);
            make.bottom.equalTo(weakSelf.mas_bottom);
            make.height.equalTo(@(ActualHeight(30)));
        }];
        
    }
    return self;
    
}


+ (instancetype)createICMTitleSubTitleViewWithTitle:(NSString *)title subtitle:(NSString *)subtitle{
    return [[ICMTitleSubTitleView alloc]initICMTitleSubTitleViewWithTitle:title subtitle:subtitle];
}

+ (instancetype)createICMTitleSubTitleViewWithTitle:(NSString *)title subtitle:(NSString *)subtitle frame:(CGRect)frame{
    return [[ICMTitleSubTitleView alloc]initICMTitleSubTitleViewWithTitle:title subtitle:subtitle frame:frame];
}


@end
